using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chapter5CustomControlsCS
{
    [ToolboxData("<{0}:ThirdSample runat=server></{0}:ThirdSample>")]
    public class ThirdSample : System.Web.UI.WebControls.WebParts.WebPart
    {
        string _BookTitle;
        protected override void CreateChildControls()
        {
            System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblBook = new System.Web.UI.WebControls.Label();

            System.Web.UI.WebControls.Table tbl = new System.Web.UI.WebControls.Table();
            System.Web.UI.WebControls.TableCell[] tc = new System.Web.UI.WebControls.TableCell[2];
            System.Web.UI.WebControls.TableRow[] tr = new System.Web.UI.WebControls.TableRow[2];

            tc[0] = new System.Web.UI.WebControls.TableCell();
            tc[1] = new System.Web.UI.WebControls.TableCell();
            tr[0] = new System.Web.UI.WebControls.TableRow();
            tr[1] = new System.Web.UI.WebControls.TableRow();
            tr[0].Cells.Add(tc[0]);
            tr[1].Cells.Add(tc[1]);
            tbl.Rows.Add(tr[0]);
            tbl.Rows.Add(tr[1]);

            lbl.Text = "Title:";
            lblBook.Text = _BookTitle;
            lblBook.Font.Bold = true;
            lblBook.BorderColor = System.Drawing.Color.Black;
            lblBook.BorderStyle = System.Web.UI.WebControls.BorderStyle.Solid;
            lblBook.BorderWidth = 1;

            tc[0].Controls.Add(lbl);
            tc[1].Controls.Add(lblBook);

            this.Controls.Add(tbl);
        }

        [System.Web.UI.WebControls.WebParts.WebBrowsable(true)]
        public string BookTitle
        {
            get 
            {
                return _BookTitle;
            }
            set 
            {
                _BookTitle = value;
            }
        }

        public override System.Web.UI.WebControls.WebParts.WebPartVerbCollection Verbs
        {
          get
            {
                System.Web.UI.WebControls.WebParts.WebPartVerb vrbEnglish = 
                            new System.Web.UI.WebControls.WebParts.WebPartVerb("vrbEnglish", this.SetEnglish);

                System.Web.UI.WebControls.WebParts.WebPartVerb vrbFrench = 
                            new System.Web.UI.WebControls.WebParts.WebPartVerb("vrbFrench", this.SetFrench);

                vrbEnglish.Text = "English";
                vrbFrench.Text = "French";
                System.Web.UI.WebControls.WebParts.WebPartVerb[] vrbsLanguage = new System.Web.UI.WebControls.WebParts.WebPartVerb[2];
                vrbsLanguage[0] = vrbFrench;
                vrbsLanguage[1] = vrbEnglish;
                System.Web.UI.WebControls.WebParts.WebPartVerbCollection vrbs;
                vrbs = new System.Web.UI.WebControls.WebParts.WebPartVerbCollection(vrbsLanguage);

                vrbEnglish.Checked = true;
                vrbEnglish.ImageUrl = "Book.Gif";
                vrbEnglish.Enabled = false;

                return vrbs;
                }
            }
        public void SetFrench(object sender, System.Web.UI.WebControls.WebParts.WebPartEventArgs e)
        {

        }

        public void SetEnglish(object sender, System.Web.UI.WebControls.WebParts.WebPartEventArgs e)
        {

        }

        }
    }
     
     